GXGetColorDistance
You can use theGXGetColorDistance
function to determine the color-space distance between two colors.
Fixed GXGetColorDistance(const gxColor *target, const gxColor *source);
target
- A pointer to the target color.
source
- A pointer to the source color.
- function result
- The color-space distance between the two colors.
DESCRIPTION
TheGXGetColorDistance
function is useful in colorimetric applications and for judging perceived closeness of colors. It calculates how similar two colors are by determining the color-space distance between them. The distance calculation is performed in the color space of the target color. If the two colors are not in the same space,GXGetColorDistance
converts the source color to the target color space before calculating the distance.If the target color space is
gxIndexedSpace
,GXGetColorDistance
uses the color space of the target color set.The distance formula used is the standard Euclidean distance:
distance = Sqrt( (b0-a0)^2 + (b1-a1)^2 + ... );SPECIAL CONSIDERATIONS
Because some of the color spaces are not linear, distances calculated in one space are not necessarily proportional to distances calculated in another space.ERRORS, WARNINGS, AND NOTICES
Errors out_of_memory color_is_nil colorSpace_out_of_range (debugging version) Warnings colorSet_index_out_of_range